package org.go.smart.temperature;

import org.go.smart.HouseController;

public class StubTemperatureController extends Thread implements TemperatureControllerApi {

	private double readTemperature = HouseController.NOT_INITIALISED_VALUE;
	private double wantedTemperature = HouseController.NOT_INITIALISED_VALUE;
	
	private WeeklyScheduler weeklyScheduler = new WeeklyScheduler();
	
	@Override
	public void run() {
		
		while(true) {
			this.readTemperature = Math.random() * 100;
			
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	
	@Override
	public double getReadTemperature() {
		return readTemperature;
	}

	@Override
	public void setWantedTemperature(final double temp) {
		this.wantedTemperature = temp;

	}

	@Override
	public double getWantedTemperature() {
		return weeklyScheduler.getWantedTemperature() == null ? this.wantedTemperature : weeklyScheduler.getWantedTemperature();
	}

}
